Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5130

AssertionError: "Conversion to relational algebra failed to preserve datatypes" when union VARCHAR literal and CAST(null AS INTEGER)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.31.0
    • 1.37.0
    • None

    Description

      0: jdbc:calcite:model=src/test/resources/mode> select CAST(null AS INTEGER) union select '10';
      java.lang.AssertionError: Conversion to relational algebra failed to preserve datatypes:
      validated type:
      RecordType(VARCHAR NOT NULL EXPR$0) NOT NULL
      converted type:
      RecordType(VARCHAR EXPR$0) NOT NULL
      rel:
      LogicalUnion(all=[false])
        LogicalValues(tuples=[[\{ null }]])
        LogicalValues(tuples=[[\{ '10' }]])
       
      at org.apache.calcite.sql2rel.SqlToRelConverter.checkConvertedType(SqlToRelConverter.java:487)
      at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:602)
      at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:257)
      at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:220)
      at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:648)
      at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:514)
      at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:484)
      at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:234)
      at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:623)
      at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:674)
      at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
      at org.apache.calcite.avatica.AvaticaStatement.execute(AvaticaStatement.java:217)
      at sqlline.Commands.executeSingleQuery(Commands.java:1130)
      at sqlline.Commands.execute(Commands.java:1079)
      at sqlline.Commands.sql(Commands.java:1033)
      at sqlline.SqlLine.dispatch(SqlLine.java:822)
      at sqlline.SqlLine.begin(SqlLine.java:596)
      at sqlline.SqlLine.start(SqlLine.java:269)
      at sqlline.SqlLine.main(SqlLine.java:208)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yingyu Yingyu Wang
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h